<template>
	<view>
		mes：<br/>
		<textarea v-model="mesData" maxlength="100000">
			
		</textarea>
		金蝶:<br/>
		<textarea v-model="jdData" maxlength="100000">
			
		</textarea>
		天剑:<br/>
		<textarea v-model="tjData" maxlength="100000">
			
		</textarea>
		共同:<br/>
		<textarea v-model="sameData" maxlength="100000">
			
		</textarea>
		<button @click="deal">
			处理
		</button>
	</view>
</template>

<script>
import { formToJSON } from 'axios';

	export default {
		data() {
			return {
				mesData:'',
				jdData:'',
				tjData:'',
				sameData:'',
				sameArr1:[],//mes包含金蝶的批次
				sameArr2:[],//mes包含天剑的批次
				sameArr3:[],//mes包含金蝶并包含天剑，三者交集
			}
		},
		onLoad() {
			
		},
		created() {
			
		},
		computed: {
	
		},
		methods: {
			deal(){
				
				var Arr1=this.mesData.split('\n');
				var Arr2=this.jdData.split('\n');
				var Arr3=this.tjData.split('\n');
				for (var i = 0; i < Arr1.length; i++) {
					var item=Arr1[i];
					var smVal=this.arrhave(Arr2,item);
					if(smVal!=''){
						this.sameArr1.push(smVal);
					}
					var smVal2=this.arrhave(Arr3,item);
					if(smVal2!=''){
						this.sameArr2.push(smVal2);
					}
				}
				for (var j = 0; j < this.sameArr1.length; j++) {
					var it2=this.sameArr1[j];
					var smVal3=this.arrhave(this.sameArr1,it2);
					if(smVal3!=''){
						this.sameArr3.push(smVal3);
					}
				}
				//显示公共数据
				this.sameData=this.appendLineInfo(this.sameArr3);
				//显示排序数据
				var newArr1=this.sortArr(Arr1,this.sameArr3);
				this.mesData=this.appendLineInfo(newArr1);
				var newArr2=this.sortArr(Arr2,this.sameArr3);
				this.jdData=this.appendLineInfo(newArr2);
				var newArr3=this.sortArr(Arr3,this.sameArr3);
				this.tjData=this.appendLineInfo(newArr3);
				
			},
			//排序
			sortArr(arr,disArr){
				var tempArr=disArr;
				for (var i = 0; i < arr.length; i++) {
					var s= arr[i];
					var sm=this.arrhave(disArr,s);
					//不包含
					if(sm==''){
						tempArr.push(s);
					}
				}
				return tempArr;
			},
			appendLineInfo(arr){
				var res='';
				for (var k = 0; k < arr.length; k++) {
					res+=arr[k]+'\n';
				}
				return res;
			},
			arrhave(arr,val){
				var re='';
				for (var i = 0; i < arr.length; i++) {
					var it=arr[i];
					
					if(val=='KGZGR60088KPY'||i==38){
						
						console.log(val,it,val.indexOf(it)>-1);
					}
					// 
					if(val.indexOf(it)>-1){
						re=it;
						console.log(val,it,val.indexOf(it)>-1);
						break;
					}
				}
				return re;
			}
		}
	}
</script>

<style>
</style>